package org.linlinjava.litemall.wx.dto;

import lombok.Data;
import org.linlinjava.litemall.db.domain.LitemallCart;
import org.linlinjava.litemall.db.domain.LitemallGrouponRules;
import org.linlinjava.litemall.db.domain.LitemallSpell;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

@Data
public class AnalysisOrderResult {
    private BigDecimal checkedGoodsPrice;
    private BigDecimal freightPrice;
    private BigDecimal couponPrice;
    private BigDecimal spellPrice;
    private BigDecimal integralPrice;
    private BigDecimal orderTotalPrice;
    private BigDecimal actualPrice;
    private BigDecimal discount;
    private BigDecimal memberPrice;
    private BigDecimal grouponPrice;
    private Boolean involveSpell;
    private Integer couponLength;
    private Integer couponId;
    private Integer userCouponId;
    private LitemallSpell spell;
    private BonusInfo bonusInfo;
    private List<LitemallCart> checkedGoodsList;
    private LitemallGrouponRules grouponRules;

    public AnalysisOrderResult() {
        this.freightPrice = BigDecimal.ZERO;
        this.couponPrice = BigDecimal.ZERO;
        this.spellPrice = BigDecimal.ZERO;
        this.integralPrice = BigDecimal.ZERO;
        this.couponLength = 0;
        this.couponId = -1;
        this.userCouponId = -1;
    }

    public void add(BigDecimal price) {
        this.actualPrice = this.actualPrice.add(price);
    }

    public void subtract(BigDecimal price) {
        this.actualPrice = this.actualPrice.subtract(price).max(new BigDecimal(0));
    }

    public void multiply(BigDecimal price) {
        this.actualPrice.multiply(price).setScale(2, RoundingMode.UP);
    }


}
